﻿using Bussiness.Interface;
using Bussiness.Service;
using Common.Model;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    /// <summary>
    /// 新书
    /// </summary>
    public List<Books> newlist = new List<Books>();

    /// <summary>
    /// 好书
    /// </summary>
    public List<Books> goodlist = new List<Books>();

    /// <summary>
    /// 教辅王牌
    /// </summary>
    public List<Books> kinglist = new List<Books>();

    public IBaseService baseService = new BaseService();

    protected void Page_Load(object sender, EventArgs e)
    {
        //if (!IsPostBack) {
            Result<List<Books>> list = new Result<List<Books>>();
            list = baseService.Select<Books>();
            if (list.Data != null) {
                try
                {
                    int limit = list.Data.Count >= 4 ? 4 : list.Data.Count;
                    newlist = list.Data.OrderBy(p => p.StockTime).Take(limit).ToList();
                    goodlist = list.Data.OrderBy(p => p.BookName).Take(limit).ToList();
                    kinglist = list.Data.OrderBy(p => p.BookType.Contains("王牌")).Take(limit).ToList();
                }
                catch (Exception ex){
                    newlist = goodlist = kinglist = null;
                }
            }
        //}
    }

    protected void SelectBook_ServerClick(object sender, EventArgs e)
    {
        Response.Write("<script>alert('dadadad')</script>");
        //LeftMenShow.aspx
    }
}